<?php
/**
 * --------------------------------------------------------------
 * 日期时间函数库
 * Author: zd <kfzphp@126.com>
 * Date: 2018-06-01
 * Project: kfzphp.com
 * --------------------------------------------------------------
 */

/**
 * 获取两个时间戳之间的所有日期
 * @param  [type]     $start  [开始时间戳]
 * @param  [type]     $end    [结束时间戳]
 * @param  string     $format [日期格式化]
 * @return [type]             [description]
 */
function between_date($start, $end, $format = 'Y-m-d')
{
    if (empty($start) || empty($end)) {
        return false;
    }
    $array = array();
    while ($start <= $end) {
        $array[] = date($format, $start);
        $start = strtotime('+1 day', $start);
    }
    return $array;
}

/**
 * 计算两日期之间的天数
 * @param  [type]     $day1 [description]
 * @param  [type]     $day2 [description]
 * @return [type]           [description]
 */
function between_days($day1, $day2)
{
    $second1 = strtotime($day1);
    $second2 = strtotime($day2);
    if ($second1 < $second2) {
        $tmp = $second2;
        $second2 = $second1;
        $second1 = $tmp;
    }
    return ($second1 - $second2) / 86400;
}
